<template>
  <el-dialog v-model="_visible" width="800">
    <template #header>
        <div>{{ props.title }}</div>
    </template>
    <el-carousel ref="carousel" trigger="click" :autoplay="false">
      <el-carousel-item v-for="(item, index) in props.urlsData" :key="index">
        <img :src="item.url" style="width:100%; height:auto;" alt="carousel"/>
      </el-carousel-item>
    </el-carousel>
  </el-dialog>
</template>

<script setup lang="ts">
import { ref, computed } from 'vue';

const props = defineProps<{
  title: string;
  visible: boolean,
  urlsData: Array<{url: string}>,
}>();

const emit = defineEmits(['update:visible']);

const _visible = computed({
  get() {
    return props.visible;
  },
  set(val) {
    emit('update:visible', val);
  },
});
</script>

<style scoped>
.el-carousel__item img {
  display: block;
  margin: 0 auto;
  max-height: 300px;
}

.el-carousel__item:nth-child(2n) {
  background-color: #99a9bf;
}

.el-carousel__item:nth-child(2n + 1) {
  background-color: #d3dce6;
}
</style>